package studio7.servlet;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.mysql.jdbc.EscapeTokenizer;

import studio7.dao.ReservaDAO;
import studio7.dao.SalaDAO;
import studio7.exception.DAOException;
import studio7.modelo.Sala;
import studio7.modelo.Servicio;

/**
 * Servlet implementation class ReservaCargarServIntr
 */
@WebServlet("/ReservaCargarServIntr")
public class ReservaCargarServIntr extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public ReservaCargarServIntr() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		SalaDAO salaDAO= new SalaDAO();
		int idSala =  222;
		Sala sala = new Sala();
		try {
			 sala = salaDAO.buscarSalaxID(idSala);
		} catch (DAOException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		}
		
		ReservaDAO reserv = new ReservaDAO();
		Collection<String> servicios = new ArrayList<String>();
		Collection<String> instrumentos = new ArrayList<String>();
		try {
			servicios = reserv.busquedaServiciosAdicionales(idSala);
			instrumentos = reserv.busquedaInstrumentosAdicionales(idSala);
		} catch (DAOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		// Guardando datos en el scope REQUEST
		request.setAttribute("SERVICIOS_ADICIONALES", servicios);

		
		request.setAttribute("INSTRUMENTOS_ADICIONALES", instrumentos);

		request.setAttribute("SALA", sala);
		
		RequestDispatcher rd = request
				.getRequestDispatcher("ReservarSala.jsp");
		rd.forward(request, response);
		
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	}

}
